#!/usr/bin/env python
# encoding:utf-8
# @Time   : 2020/3/18
# @Author : 茶葫芦
# @Site   : 
# @File   : interfaces.py

from baseHandler import BaseHandler
from main import QA
import json



class ask_question(BaseHandler):
    def post(self):
        """
        问答请求
        """
        question = self.get_argument('question')
        qa =QA()
        cypher = qa.answer(question)
        matchstatus=300 if cypher else 200
        if not question.strip():
            matchstatus = 100
        showcode = 'Sent'
        res = json.dumps({'cypher':cypher,'showcode':showcode,'matchstatus':matchstatus})
        self.write(res)

